﻿<UserControl x:Class="SharpTalk.Client.WpfApplication.Controls.UserListViewItem"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:my="clr-namespace:SharpTalk.Client.WpfApplication.Controls"
             xmlns:Resources="clr-namespace:SharpTalk.Client.WpfApplication.Resources"
             mc:Ignorable="d" 
             SnapsToDevicePixels="True"
             d:DesignHeight="59" d:DesignWidth="162"
             Height="Auto">
    <Grid>
        <Border IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource AncestorType=my:UserListViewItem}}" Background="{Binding Path=BorderBackgroundBrush, RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem}}" CornerRadius="3" Margin="3" BorderBrush="{Binding Path=CornerBrush, RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem}}" BorderThickness="{Binding Path=BorderThickness, RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem}}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition />
                    <ColumnDefinition Width="18"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Image Grid.Row="1" Style="{StaticResource ImageLargeStyle}" MaxHeight="32" MaxWidth="32" Grid.Column="0" Margin="2" Visibility="{Binding Converter={StaticResource BooleanToVisibilityConverter}, Path=ShowImage, RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem}}" Source="{Binding Path=CurrentUser.Image, RelativeSource={RelativeSource AncestorType=my:UserListViewItem}, Converter={StaticResource BinaryToBitmapImageConverter}}"/>
                <TextBlock Grid.Row="1" Foreground="{Binding Path=Foreground,RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem}}" Text="{Binding Path=CurrentUser.FullName, RelativeSource={RelativeSource AncestorType=my:UserListViewItem}}" VerticalAlignment="Center" TextWrapping="Wrap" Margin="1,1,5,1"  Grid.Column="1"/>
                <StackPanel Grid.RowSpan="2" Margin="0,1,1,1" Grid.Column="2" HorizontalAlignment="Right" Orientation="Vertical" >
                    <Button HorizontalAlignment="Left" Style="{StaticResource FlatButtonStyle}" Command="{Binding AddContactCommand, RelativeSource={RelativeSource AncestorType=my:UserListViewItem}}" CommandParameter="{Binding}" Visibility="{Binding ShowActionButtons,RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem},Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Image Width="12" Height="12" Margin="0" Style="{StaticResource ImageAddContactStyle}" ToolTip="{x:Static Resources:Messages.label_add_contact}" />
                    </Button>
                    <Button HorizontalAlignment="Left" Style="{StaticResource FlatButtonStyle}" Command="{Binding AddContactCommand, RelativeSource={RelativeSource AncestorType=my:UserListViewItem}}" CommandParameter="{Binding}" Visibility="{Binding ShowActionButtons,RelativeSource={RelativeSource FindAncestor, AncestorType=my:UserListViewItem},Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Image Width="12" Height="12" Margin="0" Style="{StaticResource ImageChatNewStyle}" ToolTip="{x:Static Resources:Messages.label_new}" />
                    </Button>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</UserControl>
